// 全局过滤器函数
// 补零函数
const padZero = n => {
        return n < 10 ? '0' + n : n
    }
    // 返回年月日时分秒
export const formatDatenyrsfm = time => {
        let date = new Date(time)
        let y = date.getFullYear()
        let M = date.getMonth() + 1
        let d = date.getDate()

        let h = date.getHours()
        let m = date.getMinutes()
        let s = date.getSeconds()

        let ret = [y, M, d, h, m, s].map(v => padZero(v))
        return ret.slice(0, 3).join('-') + ' ' + ret.slice(3).join(':')
    }
    // 返回年月日
export const formatDatenyr = time => {
        let date = new Date(time)
        let y = date.getFullYear()
        let M = date.getMonth() + 1
        let d = date.getDate()

        let ret = [y, M, d].map(v => padZero(v))
        return ret.join('-')
    }
    // 返回时分秒
export const formatDatesfm = time => {
    let date = new Date(time)
    let h = date.getHours()
    let m = date.getMinutes()
    let s = date.getSeconds()

    let ret = [h, m, s].map(v => padZero(v))
    return ret.join(':')
}

// 以下为引用的内容：
export const toThousands = num => {
    var result = [],
        counter = 0
    num = (num || 0).toString().split('')
    for (var i = num.length - 1; i >= 0; i--) {
        counter++
        result.unshift(num[i])
        if (!(counter % 3) && i != 0) {
            result.unshift(',')
        }
    }
    return result.join('')
}